home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BBS Toolkit
/
BBS Toolkit.iso
/
programs
/
lora210e.zip
/
STRUCT.ZIP
/
LASTCALL.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-04-07
|
2KB
|
79 lines
/*
Lora-CBIS Ver. 2.00
Copyright (c) 1989, 1990, 1991 by Marco Maccaferri.
All rights reserved.
Source code examples
Set/Read lastcaller record
You may use this structures at your own risk. The author cannot guarantee
that this structures are maintained in all future versions of the program.
You can freely (and you are encouraged on that) distribute this file
without limitations.
You can contact the autor at one of the following address:
Marco Maccaferri
BBS: 39-51-6331730 (2:332/402)
BIX: marco.m
*/
#include <stdio.h>
#include <io.h>
#include <time.h>
#include <fcntl.h>
#include <string.h>
#include <mem.h>
#include <sys/stat.h>
#include "lora.h"
void get_last_caller(task)
int task;
{
int fd;
struct _lastcall lastcall;
fd = open("LASTCALL.BBS", O_RDONLY|O_BINARY|O_CREAT,S_IREAD|S_IWRITE);
while (read(fd, (char *)&lastcall, sizeof(struct _lastcall)) == sizeof(struct _lastcall))
{
if (lastcall.line != task)
strcpy(lastcall.name, "None");
}
close (fd);
}
void set_last_caller(usr, task, rate)
struct _usr *usr;
int task, rate;
{
int fd;
long tempo;
struct tm *tim;
struct _lastcall lc;
fd = open("LASTCALL.BBS", O_APPEND|O_WRONLY|O_BINARY|O_CREAT,S_IREAD|S_IWRITE);
memset((char *)&lc, 0, sizeof(struct _lastcall));
lc.line = task;
strcpy(lc.name, usr->name);
strcpy(lc.city, usr->city);
lc.baud = rate;
lc.times = usr->times;
strncpy(lc.logon, &usr->ldate[11], 5);
tempo = time (NULL);
tim = localtime (&tempo);
sprintf(lc.logoff,"%2d:%02d",tim->tm_hour,tim->tm_min);
write(fd, (char *)&lc, sizeof(struct _lastcall));
close (fd);
}